package uno.component;

import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class UnoListItem extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2491070448861276172L;
	
	private JLabel nameLabel;
	private JLabel cardsNumberLabel;
	private ImageIcon img;
	private String name;
	private int number;
	private boolean leadership;
	
	public UnoListItem(String name, int number, boolean leadership) {
		
		this.name = name;
		this.number = number;
		this.leadership = leadership;
		img = new ImageIcon("img/crown.png");// non mi va di gestire le possibili eccezioni
		nameLabel = new JLabel(name);
		setMinimumSize(new Dimension(200, 20));
		initialize();
		setVisible(true);
		
	}

	private void initialize() {
		removeAll();
		if(isLeadership()){
			add(new JLabel(img));
			//System.out.println("aggiungo l'immaginina");
		}else {
			add(new JLabel());
			//System.out.println("niente immaginina");
		}
		cardsNumberLabel = new  JLabel(new Integer(number).toString());
		add(nameLabel);
		add(cardsNumberLabel);
		
	}
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
		initialize();
	}

	public boolean isLeadership() {
		return leadership;
	}

	public void setLeadership(boolean leadership) {
		this.leadership = leadership;
		initialize();
	}

}
